<html>
<head><meta charset="utf-8"><title>Collecting interesting examples? · wg-async-foundations · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/index.html">wg-async-foundations</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Collecting.20interesting.20examples.3F.html">Collecting interesting examples?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="231152696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Collecting%20interesting%20examples%3F/near/231152696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Erick Tryzelaar <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Collecting.20interesting.20examples.3F.html#231152696">(Mar 20 2021 at 15:26)</a>:</h4>
<p>Hello everyone! I love the user story idea. I was thinking through some other issues I ran into with Fuchsia, and I'm not sure how to summarize one into a user story. Is there a place to collect interesting examples, that could eventually feed into a user story?</p>
<p>we recently implement the happy eyeballs v2 rfc, in order to be resilient to flaky IPv6 support. It's pretty simple to describe, but it had a lot of interesting intersections between timers and multiple in flight connections. In short, you get a list of addresses to try from DNS, then connect to one, but after a timeout, start connecting to the next address. Repeat until either a connection succeeds, all fail, or there's no more addresses to try (where we just wait forever for it to succeed).</p>
<p>We did a lot of experimentation, but the easiest was to just implement manual future. Testing was also complicated, since we had some complex edge cases around timer expiration:</p>
<p><a href="https://cs.opensource.google/fuchsia/fuchsia/+/master:src/lib/fuchsia-hyper/src/happy_eyeballs.rs">https://cs.opensource.google/fuchsia/fuchsia/+/master:src/lib/fuchsia-hyper/src/happy_eyeballs.rs</a></p>



<a name="231155684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Collecting%20interesting%20examples%3F/near/231155684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Erick Tryzelaar <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Collecting.20interesting.20examples.3F.html#231155684">(Mar 20 2021 at 16:23)</a>:</h4>
<p>Another one (that maybe we could fit into one or more user stories) we have a number of long running state machines with our update system. One of the more complicated ones is our omaha-client service, which interacts with an omaha server, which we use to efficiently signal to a device that an update is available.</p>
<p>This includes the following interesting things:</p>
<ol>
<li>We separated this into a fuchsia-specific service, and a fuchsia-independent library, with a lot of abstract interfaces to make it all work.</li>
<li>
<p>The omaha state machine takes a while to execute, so we created some patterns to:</p>
<ul>
<li>communicate progress and metrics between the service and library</li>
<li>serializing the state machine execution while keeping the service interactive.</li>
</ul>
</li>
<li>
<p>A whole bunch of tests stressing the system. And as always, testing timers makes things difficult</p>
</li>
<li>We created a coroutine-ish library to make it easier to communicate incremental progress during the execution of the state machine: <a href="https://cs.opensource.google/fuchsia/fuchsia/+/master:src/sys/pkg/lib/async-generator/">https://cs.opensource.google/fuchsia/fuchsia/+/master:src/sys/pkg/lib/async-generator/</a></li>
</ol>
<p>service: <a href="https://cs.opensource.google/fuchsia/fuchsia/+/master:src/sys/pkg/bin/omaha-client">https://cs.opensource.google/fuchsia/fuchsia/+/master:src/sys/pkg/bin/omaha-client</a><br>
library: <a href="https://cs.opensource.google/fuchsia/fuchsia/+/master:src/sys/pkg/lib/omaha-client">https://cs.opensource.google/fuchsia/fuchsia/+/master:src/sys/pkg/lib/omaha-client</a></p>



<a name="231165354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Collecting%20interesting%20examples%3F/near/231165354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Erick Tryzelaar <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Collecting.20interesting.20examples.3F.html#231165354">(Mar 20 2021 at 19:09)</a>:</h4>
<p>Another difficult problem, but I’m not sure if it’s quite an async issue - rather than use libraries:</p>
<p>Fuchsia services talk to other services through async channels. One challenge we’ve had is how to communicate errors over these channels. By default, if we drop a channel, it will get closed by the kernel, and the other side will get a generic “PEER_CLOSED” error. However we have also these things called epitaph, that lets you add a status flag to pass along more info, like “INVALID_ARGUMENTS” to give a better hint to the peer why the channel closed. </p>
<p>Where this wg might come into play is that we don’t have linear types, so we can’t guarantee all code paths actually send an epitaph. Perhaps there are patterns we could develop, or compiler support that could improve this situation?</p>



<a name="231603867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Collecting%20interesting%20examples%3F/near/231603867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Collecting.20interesting.20examples.3F.html#231603867">(Mar 24 2021 at 09:26)</a>:</h4>
<p>These look like really interesting ideas for stories. Perhaps the best way forward is to try to break them up into individual chunks and create issues for them in the repo. </p>
<p>We don't yet have one on the question of "when is async/await not powerful enough and implementing a Future manually is the right way to go" - which is what the first story seems to be about. As for the other two stories, I'm not quite sure what their morals are. Was there a certain aspect of them that would have been easier if you had known something at the beginning that you know now? Or was there a particular piece of it that was hard to implement? The point about testing timers here is certainly an interesting one.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>